package com.zz.parkingsystem.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zz.parkingsystem.dto.PageDTO;
import com.zz.parkingsystem.entity.SystemLogin;
import com.zz.parkingsystem.entity.SystemRunning;
import com.zz.parkingsystem.mapper.SystemRunningMapper;
import com.zz.parkingsystem.service.SystemRunningService;
import com.zz.parkingsystem.vo.PageResult;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
/**
 * @author wangyuxiang
 */
@Service
public class SystemRunningServiceImpl implements SystemRunningService {
    @Resource
    private SystemRunningMapper systemRunningMapper;

    @Override
    public PageResult queryAllSystemRunning(PageDTO pageDTO) {
        Integer pageSize = pageDTO.getPageSize();
        Integer pageIndex = pageDTO.getPageIndex();
        PageHelper.startPage(pageIndex,pageSize);
        List<SystemRunning> list = systemRunningMapper.queryAllSystemRunning();
        PageInfo pageInfo = new PageInfo(list);
        PageHelper.clearPage();
        PageResult pageResult = new PageResult();
        pageResult.setPages(pageInfo.getPages());
        pageResult.setTotal((int)pageInfo.getTotal());
        pageResult.setList(list);
        return pageResult;
    }

    @Override
    public int deleteByPrimaryKey(Long id) {
        return systemRunningMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(SystemRunning record) {
        return 0;
    }

    @Override
    public int insertSelective(SystemRunning record) {
        return systemRunningMapper.insertSelective(record);
    }

    @Override
    public SystemRunning selectByPrimaryKey(Long id) {
        return systemRunningMapper.selectByPrimaryKey(id);
    }

    @Override
    public int updateByPrimaryKeySelective(SystemRunning record) {
        return systemRunningMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(SystemRunning record) {
        return 0;
    }
}
